package com.qfedu.qfoffice.service.impl;

import com.qfedu.qfoffice.dao.DepartDao;
import com.qfedu.qfoffice.entity.DepartNum;
import com.qfedu.qfoffice.entity.ResponseData;
import com.qfedu.qfoffice.service.DepartService;
import org.apache.log4j.helpers.Loader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class DepartServiceImpl implements DepartService {

    @Autowired
    private DepartDao departDao;

    @Override
    public DepartNum getDepartNum() {

       List<Map> mapList =  departDao.getDepartNum();

       List<String> departList = new ArrayList<>();

        List<Integer> departNumList = new ArrayList<>();
        for (Map map : mapList) {

           String departname = (String) map.get("name");
            Long num = (Long) map.get("num");

            departNumList.add(num.intValue());
            departList.add(departname);
        }

        DepartNum departNum = new DepartNum(departList, departNumList);



        return departNum;
    }
}
